package com.photologics.logic;

import android.app.Dialog;
import android.content.Context;
import android.content.Intent;
import android.os.Handler;
import android.view.Window;
import android.view.WindowManager;
import android.widget.ImageView;

import com.photologics.main.R;

public class SectionCloseImageDialog extends Dialog {
	ImageView closeImage;

	public SectionCloseImageDialog(Context context) {
		super(context);
		setContentView(R.layout.section_close_image_dialog);
	}

	public SectionCloseImageDialog(final Context context, final int resId) {
		super(context);
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		setContentView(R.layout.section_close_image_dialog);
		closeImage = (ImageView)findViewById(R.id.close_image);
		closeImage.setImageResource(resId);
		final Handler handler = new Handler();
		handler.postDelayed(new Runnable() {
			@Override
			public void run() {
				if(resId==R.drawable.section_fail){
					Intent intent = new Intent(context, SelectSectionActivity.class);
					context.startActivity(intent);
				}
				else{
					RandomItemDialog dialog = new RandomItemDialog(context);
					dialog.setCanceledOnTouchOutside(false);
					dialog.getWindow().clearFlags(
							WindowManager.LayoutParams.FLAG_DIM_BEHIND);
					dialog.show();
				}
				dismiss();
			}
		}, 3000);
	}

}
